473,461 Members | 1,960 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to clear combobox?

In our VB.Net Windows form application we have a combobox
pre-populated with a list of items. What I need is simply
clear everything from it's dropdown, when a button is
clicked. I tried everything I can think of, such as set
data source to nothing, etc., but still not been able to
make it happen.

Can someone show me how to do it?

Thanks

Nov 20 '05 #1
5 59412
Is it a data control?

If not, then call ComboBox1.Items.Clear

--
HTH,
-- Tom Spink, Über Geek

Woe be the day VBC.EXE says, "OrElse what?"

Please respond to the newsgroup,
so all can benefit
"feng" <an*******@discussions.microsoft.com> wrote in message
news:39****************************@phx.gbl...
In our VB.Net Windows form application we have a combobox
pre-populated with a list of items. What I need is simply
clear everything from it's dropdown, when a button is
clicked. I tried everything I can think of, such as set
data source to nothing, etc., but still not been able to
make it happen.

Can someone show me how to do it?

Thanks

Nov 20 '05 #2
* "feng" <an*******@discussions.microsoft.com> scripsit:
In our VB.Net Windows form application we have a combobox
pre-populated with a list of items. What I need is simply
clear everything from it's dropdown, when a button is
clicked. I tried everything I can think of, such as set
data source to nothing, etc., but still not been able to
make it happen.


Are you using a databound control?

Try that:

\\\
Me.ComboBox1.Items.Clear()
///

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #3
Thanks for your reply.
The Comobox1.item.clear doesn't seem to work properly
since have datasource set - I am getting an error message
about this. When I try to set Comobox1.DataSource =
Nothing then I can clear the list, but I still have one
line displyed in the combo: System.Data.DataRowView. What
should I do with this?

Thanks
-----Original Message-----
* "feng" <an*******@discussions.microsoft.com> scripsit:
In our VB.Net Windows form application we have a combobox pre-populated with a list of items. What I need is simply clear everything from it's dropdown, when a button is
clicked. I tried everything I can think of, such as set
data source to nothing, etc., but still not been able to make it happen.


Are you using a databound control?

Try that:

\\\
Me.ComboBox1.Items.Clear()
///

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
.

Nov 20 '05 #4
You have to set the data source = nothing
before issuing ..items.clear

jc

"feng" <an*******@discussions.microsoft.com> wrote in message
news:39****************************@phx.gbl...
Thanks for your reply.
The Comobox1.item.clear doesn't seem to work properly
since have datasource set - I am getting an error message
about this. When I try to set Comobox1.DataSource =
Nothing then I can clear the list, but I still have one
line displyed in the combo: System.Data.DataRowView. What
should I do with this?

Thanks
-----Original Message-----
* "feng" <an*******@discussions.microsoft.com> scripsit:
In our VB.Net Windows form application we have a combobox pre-populated with a list of items. What I need is simply clear everything from it's dropdown, when a button is
clicked. I tried everything I can think of, such as set
data source to nothing, etc., but still not been able to make it happen.


Are you using a databound control?

Try that:

\\\
Me.ComboBox1.Items.Clear()
///

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
.

Nov 20 '05 #5
Have you tried calling DataTable.Clear on the table that it's bound to?
"feng" <an*******@discussions.microsoft.com> wrote in message
news:39****************************@phx.gbl...
In our VB.Net Windows form application we have a combobox
pre-populated with a list of items. What I need is simply
clear everything from it's dropdown, when a button is
clicked. I tried everything I can think of, such as set
data source to nothing, etc., but still not been able to
make it happen.

Can someone show me how to do it?

Thanks

Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: stingrays | last post by:
Below is my code for a combobox. Basically, I have 2 comboboxes. 1 box is the application selection and the other retrieves data from the dataset (SQL Server) to populate the drop down in the...
4
by: Keith Smith | last post by:
Is there an easier way to clear all of the comboBoxes on my form? I am currently using this code... autoCompleteComboBox1.Text=""; autoCompleteComboBox1.SelectedText=""; ...
1
by: mdb | last post by:
I currently catch the SelectedIndexChanged event on a ComboBox to perform some processing when the user changes the selected item. But I also want to know when the user clears the list, but I...
1
by: Rob R. Ainscough | last post by:
What I'm trying to accomplish is: Disable a ComboBox (not bound to any data) when a .Clear method is executed. So far a cboComboBox.Items.Clear does NOT trigger any of the events I expected it...
13
by: KKuser | last post by:
Hello: I have 20, 30 text and combo boxes on one form, and I would like to clear them up at one time using the statement "With..........End With". I used this when using VB6, but I don't know...
3
by: samoore33 | last post by:
I am populating a ComboBox at run time. I insert the first value of "Choose Value" cboTaxValue.Item.Insert(0, "Choose Value") Then I loop through the rest of the values to be added to the...
0
by: sixths3ns3 | last post by:
My DataGridView has two columns. Combobox Column 2 displays list based on Combobox Column 1 selected value. The code below works fine when I select a value on Column 1, and select a value on Column...
1
by: Minou | last post by:
How to clear a combobox in VBA?
5
aas4mis
by: aas4mis | last post by:
I haven't had much luck with specific controls, their properties and loops in the past. I thought I would share this tidbit of code, feel free to modify/modularize in any way to suit your needs. This...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.